package cn.edu.scau.cmi.chenjiale.integration.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;

import cn.edu.scau.cmi.chenjiale.integration.entity.Teacher;
import cn.edu.scau.cmi.chenjiale.integration.utils.DBUtils;

/**
 * 老师Dao
 * 
 * @author chen.jiale
 * @date 2019/05/18
 *
 */
public class TeacherDao {
	public boolean getById(Teacher teacher) {
		Session session = DBUtils.session();
		session.saveOrUpdate(teacher);
		DBUtils.commitTransactionAndClose(session);
		return true;
	}

	@SuppressWarnings("unchecked")
	public List<Teacher> list() {
		Session session = DBUtils.session();
		Query query = session.createQuery("from Teacher");
		List<Teacher> teacherList = query.list();
		return teacherList;
	}
}
